<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${cuinfo.cname}</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>css/system.css" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_389729_ln4520tk0oo.css" media="all">
<script type="text/javascript" src="<%=basePath%>js/qualify/zizhisel.js"></script>
<script type="text/javascript" src="<%=basePath%>js/jobsel/job.js"></script>

<style type="text/css">
.enteringhide { display: block;}
.qymc p { display: block; border-bottom: 1px solid #cccccc; }
.wybsf p { display: block; border-bottom: 1px solid #cccccc; }

  
/* 增行弹窗 */
.addlxjl,.addyyjl,.addlxrtc,.addxqtc,.addwjtc { display:none; }
.tc_customercontactsdiv,.tc_customercategorydiv,.tc_customerfilediv { margin: 10px 0 0 0; }
.customtext {height: 30px; width: 265px; font-size: 16px; border: 1px solid #e6e6e6;}
.tc_customercategorydiv .customselect { height: 30px; width: 80px; font-size: 16px;}
.tc_btndiv { margin-top: 30px; text-align: center; }
.tc_btndiv .tc_savebtn { width: 100px; height: 40px; text-align: center; border: 0;
			background-color: #a48ad4; cursor: pointer; border-radius: 2px; font-size: 18px; color: rgb(255, 255, 255);}
.tc_customercategorydiv .categoryselect .layui-input-inline { width: 268px; }

/* 隐藏显示 */
.hideadd { display: none; }
.showadd { display: block; }

/* 必填前的红点 */
.layui-form-label {font-weight:bold }
.layui-form-label i { color:red; padding-right: 3px; }
.layui-form-label span {font-weight:bold }
  .highlight{background:yellow;color:red;}
        .zhititle{font-size:16px;color:#333;text-align:center;margin:30px 0 30px 0;}
        #btnSearch{width:60px;height:30px;margin:30px 0 30px 30px;}
        #txtKey{width:40%;height:30px;margin:30px 0 30px 30px;}
        #pretime div{margin-left:20px;margin-bottom:30px;}
        #pretime p{font-size:16px;color:#333;text-indent:33px;}
.site-table tbody tr td {
    text-align: left;
}

		.hidden { display: none !important; }
 		.selectPickerWrapper *{box-sizing: border-box;}
 		.selectPickerWrapper{    position: relative;
    margin-top: 5px;
    display: inline-block;
    background-color: white;}
		.select-picker-search{width:300px;height:32px;line-height:32px;color:#666;border-radius:3px;border:1px solid #ddd;padding:0 10px;font-size:14px;cursor:pointer;}
		.select-picker-search-checked{position:relative;width:280px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;padding-right: 5px;}
		.select-picker-search-checked:after{
			border: 5px solid transparent; content: ' ';
		    height: 0; position: absolute;
		    width: 0; top:12.2px; border-top: 8px solid #666; right:0; }
		.select-picker-options-wrp{display:none;width:200px;border-radius: 2px;box-shadow: 0 1px 5px rgba(0,0,0,.2);background-color: #fff;position:absolute;top:36px;left:0;z-index:999;}
		.select-picker-options-serch input{width:160px;height:32px;line-height:32px;border:1px solid #ddd;border-radius:3px;margin:12px 0 0 10px;padding-left:8px;}
		.select-picker-options-serch input:focus{border-color: #66afe9;outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6); box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6)}
		.select-picker-options-list{width:100%;padding:8px 0;}
		.select-picker-options-list-item{width:100%;line-height:36px;cursor: pointer;padding:0 12px;}
		.select-picker-options-list-item:hover{background: #ebf1f5;}
		.duihao {display:inline-block;width:18px;height:18px;border-radius:3px;transform: translateY(4px);margin-right:6px;}
		.duihao-checked {  background:#00a0ff; position: relative; }
	    .duihao-checked:before, .duihao-checked::after {
	        content:""; height:10px; width:2px;
	        border-radius: 10px; display:block;
	        background:white; position: absolute;
	        top:4px;  left:10px; 
	        transform:rotate(45deg);-ms-transform:rotate(45deg);    
	    }
	    .duihao-checked::before {
	        height:6px; transform: rotate(-45deg); -ms-transform:rotate(-45deg);
	        position: absolute;  top:7px; left:5px;       
	    }
	    .duihao-nocheck{border:1px solid #ddd;}
</style>
</head>
<body>

<div class="admin-tab TM-tab admin-entering">
    <form class="layui-form" action="" id="enterform">
    	<div class="layui-field-box entering-box">
    	<div class="entering">
            <h4>基本信息&nbsp;&nbsp;<button lay-submit="" lay-filter="save"class="layui-btn layui-btn-primary layui-btn-small" data="1">保存</button>
            	<button class="layui-btn layui-btn-primary layui-btn-small refreshbtn" type="button"><i class="layui-icon">&#x1002;</i>刷新</button>
            </h4>
            <table class="site-table table-hover">
            <tr>
            <td>
            <div class="layui-form-item">
                <label class="layui-form-label">资源类型 : </label>
                <div class="layui-input-block"  style="margin-left: 98px;" >  
                    <dic:cf type="3"   inputName="iszj"   name="customer_zj_qy"  value="${cuinfo.iszj!=null?cuinfo.iszj:0}"    />
                </div>  
            </div>
         <div class="layui-form-item">
                <label class="layui-form-label">合作意向 : </label>
                <div class="layui-input-block"   style="margin-left: 98px;" > 
                    <dic:cf type="3"   inputName="paperspurpose"   name="customer_purpose"  value="${cuinfo.paperspurpose!=null?cuinfo.paperspurpose:1}"    />
                </div>
            </div>
	    
            <div class="layui-form-item">
                <label class="layui-form-label">业务标签 : </label>
                <div class="layui-input-block" style="margin-left: 98px;width:70%"   >  
                   <input type="hidden" name="tags" id="tags"  value="${cuinfo.tags}"    autocomplete="off" class="layui-input">
             	   <div id="demo2" class="selectPickerWrapper">
				        <select  lay-ignore class="hidden" multiple="multiple">
				          <dic:cf type="2" name="customer_tags" value=""/>
				        </select>
				    </div>
             	 </div>
            </div>
            <div class="form-left" style="margin-top:6px;">
	                <div class="layui-form-item" >
                <label class="layui-form-label"><i>*</i><span>企业名称 : </span></label>
                <div class="layui-input-inline qymc" style="text-align: left; width: 60%;">
                	<c:if test="${customerid != null && customerid > 0}">
                		<p>${cuinfo.cname}</p>
                	</c:if>
                	<c:if test="${customerid == 0 || customerid == null }">
                		<input type="text" name="cname" id="cname"   autocomplete="off" class="layui-input">
                	</c:if>
                </div>
            </div>
            <c:if test="${customerid == 0 || customerid == null }">
                <div class="layui-form-item">
	            	<label class="layui-form-label"><i>*</i><span>联系人 : </span></label>
	                <div class="layui-input-inline">
	                	<input type="text" name="name" id="names"   autocomplete="off" class="layui-input">
	                </div>
            	</div>
            </c:if>
      
            <div class="layui-form-item address">
                <label class="layui-form-label">地址 : </label>
                <div class="layui-input-inline" style="width:380px;">
               <%--  <c:set var="cp" value="${cuinfo.province}" property="cp"/>
                <c:if test="${curp != null }">
                	<c:set var="cp" value="${curp}" property="cp"/>
                </c:if>
                    <select name="province" id="province"  lay-filter="province" class="provinceclass" >
                        <option value="-1" selected>请选择省</option>
                        <c:forEach var="prov" items="${province}" varStatus="p1">
                        	<option value="${prov.id}"  <c:if test="${cp==prov.id}">selected</c:if>>${prov.provincename}</option>
                        </c:forEach>
                    </select> --%>
                    <input type="text" name="address" id="address"  value="${cuinfo.address}"  autocomplete="off" class="layui-input">
                </div>
 	    </div>
            <div class="layui-form-item address">
                <label class="layui-form-label">税务账号 </label>
                <div class="layui-input-inline" style="width:180px;">
 
                    <input type="text" name="account" id="account"  value="${cuinfo.account}"  autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">密码 </label>
                <div class="layui-input-inline" >
 
                    <input type="text" name="password" id="password"  value="${cuinfo.password}"  autocomplete="off" class="layui-input">
               
 		</div>
            </div>
            <div class="layui-form-item warehouse">
	            <label class="layui-form-label">客户来源 : </label>
	            <div class="layui-input-inline">
	                   <select name="source" id="source">
	                       <option value="0">请选择客户来源</option>
	                       <dic:cf type="2" name="customer_source" value="${cuinfo.source}"/>
	                   </select>
	             </div>
             </div>
            <div class="layui-form-item layui-form-text">
	            <label class="layui-form-label">资质等级</label>
	            <div class="layui-input-inline TM-textarea-inline" style="width:60%;">
	                <textarea placeholder="请输入内容" class="layui-textarea" id="zzleval" name="zzleval">${cuinfo.zzleval}</textarea>
	            </div>
           </div>
           <div class="layui-form-item layui-form-text">
          <label class="layui-form-label">协作人</label>
 		     <div class="layui-input-inline"  style="width: 50%;position:relative;">  
             		<!--   <a href="#" class="layui-btn layui-btn-primary layui-btn-small gathering" >添加协作人</a>  -->
             	   <input name="xzuser" id="xzuser" value="${cuinfo.xzuser}" type="hidden">
             	   <div id="demo1" class="selectPickerWrapper">
				        <select  lay-ignore class="hidden" multiple="multiple">
				           <c:forEach var="nameobj" items="${userlist}">
                    		<option value="${nameobj.uid}" <c:if test="${ nameobj.uid == pager.params.uid }">selected</c:if> >${nameobj.name}</option>
                    	  </c:forEach>
				        </select>
				    </div>
             	 </div>
             	  <label class="layui-form-label" style="width: 30%;margin-left:-168px"> 资源归属人：${cuinfo.createusersname}</label>
           </div>
        </div>

        <div class="form-right" style="width:42%">
             
            <c:if test="${customerid == 0 || customerid == null }">
	            <div class="layui-form-item">
	            	<label class="layui-form-label"><i>*</i><span>联系电话 : </span></label>
	                <div class="layui-input-inline">
	                	<input type="text" name="tel" id="tel"   autocomplete="off" class="layui-input">
	                </div>
	            </div>
            </c:if>
            <div class="layui-form-item">
                <label class="layui-form-label">录入时间 : </label>
                <div class="layui-input-inline">
                    <input type="text" name="createdate" id="createdate" value="${ cuinfo.createdate.substring(0,10) }" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
                </div>
            </div>
            <div class="layui-form-item warehouse">
                <label class="layui-form-label">成熟等级 : </label>
                <div class="layui-input-inline">
                    <select name="state" id="state">
                        <c:if test="${cuinfo.state==4 || state == 4}">  <option value="4"  selected >公共资源</option></c:if>
                        <c:if test="${cuinfo.state!=4}">
                          <option value="0" <c:if test="${cuinfo.state==0 || state == 0}">selected</c:if>>最新资源</option> 
                           <option value="1" <c:if test="${cuinfo.state==1 || state == 1}">selected</c:if>>意向不明</option> 
                          <option value="6" <c:if test="${cuinfo.state==6 || state == 6}">selected</c:if>>意向明确</option>
                          <option value="5" <c:if test="${cuinfo.state==5 || state == 5}">selected</c:if>>意向强烈</option>
                          <option value="7" <c:if test="${cuinfo.state==7 || state == 7}">selected</c:if>>合作客户</option> 
                        </c:if>
                    </select>
                </div>
            </div>
  	    <div class="layui-form-item address">
                <label class="layui-form-label">企业锁 </label>
                <div class="layui-input-inline" style="width:180px;">
 
                    <input type="text" name="accounttwo" id="accounttwo"   value="${cuinfo.accounttwo}"  autocomplete="off" class="layui-input">
                </div>
                <label class="layui-form-label">密码 </label>
                <div class="layui-input-inline" >
 
                    <input type="text" name="passwordtwo" id="passwordtwo"  value="${cuinfo.passwordtwo}"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item warehouse">
            	<label class="layui-form-label ">客户分类 : </label>
                <div class="layui-input-inline">
                    <select name="level" id="level">
                    	<option value="0" <c:if test="${cuinfo.level == null || cuinfo.level < 1}">selected</c:if>  >客户分类</option>
                    	<option value="1" <c:if test="${cuinfo.level == 1}">selected</c:if> >小客户</option>
                    	<option value="2" <c:if test="${cuinfo.level == 2}">selected</c:if> >普通客户</option>
                    	<option value="3" <c:if test="${cuinfo.level == 3}">selected</c:if> >重点客户</option>
                    	<option value="4" <c:if test="${cuinfo.level == 4}">selected</c:if> >优质客户</option>
                    </select>
                </div>
            </div>
             <div class="layui-form-item layui-form-text">
	            <label class="layui-form-label">企业要求</label>
	            <div class="layui-input-inline TM-textarea-inline" style="width:60%;">
	                <textarea placeholder="请输入内容" class="layui-textarea" id="summary" name="summary">${cuinfo.summary}</textarea>
            	</div>
      	  	</div>
        </div>
        <div class="layui-form-item TM-save-item">
            <div class="layui-input-block">
            	<input type="hidden" value="${customerid}" id="id" name="id" >
            	<input type="hidden" value="${type}" id="type" name="type">
            	<input type="hidden" value="${state}" id="states" name="states">
                <!-- <button class="layui-btn save-btn" lay-submit="" lay-filter="save">保存</button> -->
            </div>
        </div>
            </td>
            </tr></table></div></div>

    </form>
    
	<!-- 这里现在用showadd和hideadd控制 -->
	<div class="layui-field-box entering-box hideadd <c:if test="${customerid != null && customerid > 0 }"> showadd </c:if>">
        <div class="entering">
           <h4>联系人&nbsp;&nbsp; <button class="layui-btn layui-btn-primary layui-btn-small addlxr" data="1">+添加联系人</button>  <a class="layui-btn layui-btn-primary layui-btn-small" href="https://www.tianyancha.com/search?key=${cuinfo.cname}&checkFrom=searchBox" target="_blank">天眼查</a><a class="layui-btn layui-btn-primary layui-btn-small" href="http://www.qixin.com/search?key=${cuinfo.cname}&page=1" target="_blank">启信宝</a><a class="layui-btn layui-btn-primary layui-btn-small" href="http://www.qichacha.com/search?key=${cuinfo.cname}" target="_blank">企查查</a> <a class="layui-btn layui-btn-primary layui-btn-small" href="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=${cuinfo.cname}%20%E7%94%B5%E8%AF%9D%7C%E6%89%8B%E6%9C%BA%7C%E8%81%94%E7%B3%BB%E6%96%B9%E5%BC%8F%7C%E8%81%94%E7%B3%BB%E4%BA%BA&oq=%25E5%25AE%2589%25E5%25BE%25BD%25E8%258F%25AF%25E5%258A%259B%25E5%25BB%25BA%25E8%25AE%25BE%25E9%259B%2586%25E5%259B%25A2%25E6%259C%2589%25E9%2599%2590%25E5%2585%25AC%25E5%258F%25B8%2520%25E7%2594%25B5%25E8%25AF%259D%257C%25E6%2589%258B%25E6%259C%25BA%257C%25E8%2581%2594%25E7%25B3%25BB%25E6%2596%25B9%25E5%25BC%258F%257C%25E8%2581%2594%25E7%25B3%25BB%25E4%25BA%25BA&rsv_pq=d315c4d30002bfd4&rsv_t=5a8do7P%2FOMZlNnccc%2BBLo6ME7pHarxaLJMlks8qPm4FNAnUOb%2BvJr4tlAPY&rqlang=cn&rsv_enter=0&rsv_sug3=59&inputT=11681&rsv_sug4=11681" target="_blank">百度查询</a><a class="layui-btn layui-btn-primary layui-btn-small" href="javascript:;" id="toqyzjbcx">一级锁查询</a><a class="layui-btn layui-btn-primary layui-btn-small" href="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=${cuinfo.cname}%20%E6%8B%9B%E8%81%98%20site%3Aganji.com%20&rsv_pq=8099104f00016549&rsv_t=a952tjkGou%2BsoEdMQyAGDkuGhJB6t6sQxYewE%2BVUYkZ4b4rE4A4Ud0J1IWI&rqlang=cn&rsv_enter=0&rsv_n=2&rsv_sug3=1&inputT=1152&rsv_sug4=1152" target="_blank">赶集</a>
<a class="layui-btn layui-btn-primary layui-btn-small" href="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=${cuinfo.cname}%20%E6%8B%9B%E8%81%98%20site%3Aqy.58.com%20&rsv_pq=8099104f00016549&rsv_t=a952tjkGou%2BsoEdMQyAGDkuGhJB6t6sQxYewE%2BVUYkZ4b4rE4A4Ud0J1IWI&rqlang=cn&rsv_enter=0&rsv_n=2&rsv_sug3=1&inputT=1152&rsv_sug4=1152" target="_blank">58</a>
<a class="layui-btn layui-btn-primary layui-btn-small" href="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=${cuinfo.cname}%20%E6%8B%9B%E8%81%98%20site%3Achinahr.com%20&rsv_pq=8099104f00016549&rsv_t=a952tjkGou%2BsoEdMQyAGDkuGhJB6t6sQxYewE%2BVUYkZ4b4rE4A4Ud0J1IWI&rqlang=cn&rsv_enter=0&rsv_n=2&rsv_sug3=1&inputT=1152&rsv_sug4=1152" target="_blank">中华英才</a><a class="layui-btn layui-btn-primary layui-btn-small" href="javascript:;" id="toqyzzcx">企业资质查询</a> </h4>
            <table class="site-table table-hover TM-table3">
                <thead>
                <tr>
                    <th style="width:145px;">姓名</th>
                    <th style="width:145px;">联系电话</th>
                    <th style="width:145px;">QQ号</th>
                    <th style="width:145px;">微信号</th>
                    <th style="width:170px;">操作</th>
                </tr>
                </thead>
                <tbody class="tb_customercontacts">
				 <c:forEach var="conobj" items="${cuinfo.contactsItem}" varStatus="con">
				 	<tr class="conttr${conobj.id}" data="${conobj.id}">
	                    <td>${conobj.name}<c:if test="${conobj.ismain==1}">[主要联系人]</c:if></td>
	                    <td>${conobj.phone}</td>
	                    <td>${conobj.qq}</td>
	                    <td>${conobj.webchart}</td>
	                    <td>
	                    	<button class='layui-btn layui-btn-primary layui-btn-small updatecustomercontacts' type='button'>修改<i class='layui-icon'></i></button>
	                    	<button class='layui-btn layui-btn-primary layui-btn-small deletecustomercontacts' type='button'>删除<i class='layui-icon'></i></button>
	                    	<c:if test="${conobj.ismain!=1}"><button class='layui-btn layui-btn-primary layui-btn-small maincustomercontacts' type='button'  did="${conobj.id}"  dcusid="${conobj.cusid}">主联系人<i class='layui-icon'></i></button></c:if>
	                    </td>
                	</tr>
				 </c:forEach>
                </tbody>
            </table>
            <input type="hidden" name="linetype" id="linetype1" value="1">
        </div>
        <div class="entering">
 <h4>业务记录(共 <i>${fn:length(cuinfo.filesItem)}</i> 条) &nbsp;&nbsp;<button class="layui-btn layui-btn-primary layui-btn-small addwj" data="3">+添加业务记录</button></h4>
            <form action="" method="post" enctype="multipart/form-data" id="customerfileform">
            <table class="site-table table-hover TM-table3">
                <thead>
                <tr>
                   <!--  <th style="width:50px;">序号</th>
                    <th style="width:160px;">文件名</th>
                    <th style="width:130px;">文件大小</th>
                    <th style="width:120px;">备注</th>
                    <th style="width:140px;">操作</th> -->
                    
                     <th style="width:105px;">业务名称</th>
                    <th style="width:225px;">业务备注</th>
                    <th style="width:145px;">文件下载</th>
                    <th style="width:105px;">处理时间</th>
                    <th style="width:170px;">操作人</th>
                </tr>
                </thead>
                <tbody class="tb_customerfile">
                <c:forEach var="fileobj" items="${cuinfo.filesItem}" varStatus="file">
                	<tr class="filetr${fileobj.id}" data="${fileobj.id}"> 
	                    <td> <dic:cf type="1"     name="customer_business"  value="${fileobj.type}"   /></td>
	                    <td>${fileobj.remark}</td>
	                    <td><button class="layui-btn layui-btn-primary layui-btn-small downloadcunstomerfilesbtn" type='button' data="${fileobj.filesinfo.id}">下载<i class="layui-icon"></i></button></td>
	                    <td class="fielremark">${fileobj.createdate.substring(0,10)}</td>
	                    <td>
	                    	<button class="layui-btn layui-btn-primary layui-btn-small addwj" type='button' dataid="${fileobj.id}">修改<i class="layui-icon "></i></button>
	                    	 	<c:if test="${fileobj.filesinfo.suffix=='png'||fileobj.filesinfo.suffix=='jpg'||fileobj.filesinfo.suffix=='gif'}">
	                   
	                    <button class="layui-btn layui-btn-primary layui-btn-small downloadcunstomerfilesbtntwo" type='button' data="${fileobj.filesinfo.id}">预览<i class="layui-icon"></i></button>
	                    </c:if>
	                    <c:if test="${sessionScope.user.id==1}">
				                 <button class="layui-btn layui-btn-primary layui-btn-small detelecustomerfilebtn" type='button' data="${fileobj.id}">删除<i class="layui-icon "></i></button>
				           </c:if>
	                    </td>
                	</tr>
                </c:forEach>
                </tbody>
            </table>
            </form>
        </div>
	
	   <div class="entering">
            <h4>挂靠人员&nbsp;&nbsp; <button class="layui-btn layui-btn-primary layui-btn-small tjrybtn" data="1">+聘用人员</button>  </h4>
            <table class="site-table table-hover TM-table3">
                <thead>
                <tr>
                   <th style="width:8%;">人员</th>
					<th style="width:20%;">证书及专业</th>
					<th style="width:10%;">状态</th>
					<th style="width:15%;">聘用时间</th>
					<th style="width:15%;">证书到期时间</th>
					<th style="width:10%;">所属人</th>
					<th style="width:10%;">操作</th>
                </tr>
                </thead>
                <tbody class="tb_customercontacts">
				  
							<c:forEach var="obj" items="${cuinfo.gaokaoUser}" varStatus="o1">
							   <tr>
									<td>${obj.cname}</td>
								
									<td>
										${obj.technicalpost}
									</td>
									<td >
									   <font color="green">已聘用</font>
									</td>
									<td><c:if test="${obj.createdate!=null}">${obj.createdate.substring(0,10)} </c:if> </td>
									 <td> <c:if test="${obj.endtime!=null}">${obj.endtime.substring(0,10)} </c:if>    </td>
									 <td>${obj.createusersname} </td>
									 <td> <button class="layui-btn layui-btn-danger layui-btn-small jpbtn" data="${obj.quid}"   type="button">解聘<i class="layui-icon"></i></button>
									  <button class="layui-btn layui-btn-danger layui-btn-small pytimejpbtn" data="${obj.quid}"   type="button">调整聘用时间<i class="layui-icon"></i></button>
									 
									  </td>
								</tr>
							</c:forEach>
					  
                </tbody>
            </table>
            <input type="hidden" name="linetype" id="linetype1" value="1">
        </div>
	
	
	 
         <div class="entering  hideadd  <c:if test='${customerid != null && customerid > 0 && cuinfo.state!=4  }'> showadd </c:if>">
           
            <h4>需求&nbsp;&nbsp;<button class="layui-btn layui-btn-primary layui-btn-small addxq" data="2">+添加需求</button></h4>
            <form  class="layui-form" action="" method="post" id="savecustomercategoryform">
                <table class="site-table table-hover TM-table3">
	                <thead>
		                <tr>
		                      <th style="width:15%;">证件类型</th>
		                    <th style="width:5%;">证件数量</th>
		                    <th style="width:10%;">性质</th>
		                    <th style="width:10%;">用途</th>
		                    <th style="width:30%;">备注</th>
		                    <th style="width:20%;">操作</th>
		                </tr>
	                </thead>
                    <tbody class="tb_customercategory">
                    	<c:forEach var="catobj" items="${cuinfo.categoryItem}" varStatus="cat"> 
		                	<tr class="catetr${catobj.id}" data="${catobj.id}">
					 <td><c:if test="${catobj.buystate==0}"><i class="iconfont icon-maichu " style="color:red;font-size: 19px;"></i></c:if><c:if test="${catobj.buystate==1}"><i class="iconfont icon-mairu " style="color:#00e200;font-size: 19px;"></i></c:if>&nbsp;${catobj.categoryname}<%-- <dic:cf value="${catobj.category}" name="build_category" type="1"/> --%></td>
			                	<td>${catobj.count}本</td>
			                	<td>
				                	<c:if test="${catobj.types == 1}">
				                		初始
				                	</c:if>
				                	<c:if test="${catobj.types == 2}">
				                		转注
				                	</c:if>
				                	<c:if test="${catobj.types == 3}">
				                		初转不限
				                	</c:if>
				                	<c:if test="${catobj.types == 4}">
				                		项目
				                	</c:if>
			                	</td>
			                	<td>
			                		<c:if test="${catobj.paperspurpose == 1}">
			                			入库
			                		</c:if>
			                		<c:if test="${catobj.paperspurpose == 2}">
			                			项目
			                		</c:if>
			                		<c:if test="${catobj.paperspurpose == 3}">
			                			动态核查
			                		</c:if>
			                		<c:if test="${catobj.paperspurpose == 0}">
			                			其他
			                		</c:if>
			                	</td>
			                	<td>${catobj.remark}</td>
			                	<td>

			                	 <!--	<button class='layui-btn layui-btn-primary layui-btn-small updatecustomercategory' type='button'>修改<i class='layui-icon'></i></button> -->
			                		<button class='layui-btn layui-btn-primary layui-btn-small deletecategory' type='button'>删除<i class='layui-icon'></i></button>
			                	</td>
		                	</tr>
		                </c:forEach>
                    </tbody>
                </table>
            </form>
        </div>  
        <div class="entering">
            <h4>跟进记录 &nbsp;&nbsp;<button class="layui-btn layui-btn-primary layui-btn-small lxjladd" data="4">+添加跟进记录</button></h4>
            <table class="site-table table-hover TM-table3">
                <thead>
                <tr>
                    <th style="width:10%;">联系人</th>
                    <th style="width:15%">跟进时间</th>
                    <th style="width:60%">跟进内容</th>
                    <th style="width:15%;">跟进人</th>
                </tr>
                </thead>
                <tbody class=" lxjlbody">
                <c:forEach var="lxobj" items="${lxpager.resultList}" varStatus="lx">
                		<tr>
	                		<td>${lxobj.name}</td>
	                		<td>${lxobj.updatedate.substring(0,10)} ${lxobj.updatedate.substring(10,16)}</td>
	                		<td>${lxobj.remark}</td>
	                		<td>${lxobj.uname}</td>
                		</tr>
                	</c:forEach>
                	
                </tbody>
                <tfoot  >
                  <tr>
                  <td colspan="4">
	                   <div class="admin-table-page">
			   				<div id="page" class="page"></div>
						</div> 
				   </td>
                   </tr>
                </tfoot>
            </table>
           
            <input type="hidden" name="linetype" id="linetype1" value="1">
        </div>
        <div class="entering">
            <h4>预约记录 &nbsp;&nbsp;<button class="layui-btn layui-btn-primary layui-btn-small yyjladd" data="5">+添加预约</button></h4>
            <table class="site-table table-hover TM-table3">
                <thead>
                <tr>
                	<th style="width:10%;">预约人</th>
                    <th style="width:15%;">预约时间</th>
                    <th style="width:75%;">预约内容</th>
                </tr>
                </thead>
                <tbody class="">
                	<c:forEach var="yyobj" items="${yypager.resultList}" varStatus="yy">
                		<tr>
                			<td>${yyobj.uname}</td>
	                		<td>${yyobj.stime.substring(0,10)} ${yyobj.stime.substring(10,16)}</td>
	                		<td>${yyobj.remark}</td>
                		</tr>
                	</c:forEach>
                </tbody>
            </table>
            <input type="hidden" name="linetype" id="linetype1" value="1">
        </div>
         
    </div>
    
    
    <!-- <form class="layui-form" id="tjlxjlForm" action="">
	      <div class="layui-form-item address" style="margin-top:10px">
	            <label class="layui-form-label">联系人： </label>
	            <div class="layui-input-block" style="width:60%">
	                  <select name="contact" id="contact"  lay-filter="contact">
	                    	<option value="">请选择</option>
	                 </select>
	            </div>
	        </div>
		     <div class="layui-form-item layui-form-text">
			    <label class="layui-form-label">备注：</label>
			    <div class="layui-input-block" style="width:60%">
			      <textarea id="remark" name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
			        <input name="id" id="jlid" type="hidden" value="0">
			    </div>
			 </div>
	    </form> -->
    <!-- 联系人弹窗 -->
    <div class="addlxrtc">
    	<form class="layui-form" action="" id="tc_customercontactsform">
			<div class="tc_customercontactsdiv"style="padding-top:10px;">
	    		<div class="layui-form-item">
	            	<label class="layui-form-label"><i>*</i><span>姓名 : </span></label>
	            	<div class="layui-input-inline" style="width:70%">
	            		<input type="text" class="layui-input  " id="name" name="name">
	            	</div>
	            </div>
	            <div class="layui-form-item">
	            	<label class="layui-form-label"><i>*</i><span>联系电话 : </span></label>
	            	 <div class="layui-input-inline" style="width:70%">
	            		<input type="text" class="layui-input" id="phone" name="phone">
	            	</div>
	            </div>
	            <div class="layui-form-item">
	            	<label class="layui-form-label">QQ : </label>
	            	 <div class="layui-input-inline" style="width:70%">
	            		<input type="text" class="layui-input" id="qq" name="qq">
	            	</div>
	            </div>   
	            <div class="layui-form-item">
	            	<label class="layui-form-label">微信 : </label>
	            	 <div class="layui-input-inline" style="width:70%">
	            		<input type="text" class="layui-input" id="webchart" name="webchart">
	            	</div>
	            </div>
	            <div class="layui-form-item tc_btndiv">
	            	<input type="hidden" value="0" id="contactsid" value="">
	            	<!-- <input type="submit" value="保存" class="tc_savebtn"> -->
	            </div>        
			</div>
    	</form>
    </div>
    
 <!-- 需求弹窗 -->
     <div class="addxqtc">
   		<form action="" id="tc_savecustomercategoryform"  class="layui-form" >
   			<div class="tc_customercategorydiv"style="padding-top:10px;">
	   			<div class="layui-form-item">
	   				<label class="layui-form-label"><i>*</i><span>证件类型 : </span></label>
	   				<div class="layui-input-inline" style="width:80%">
	            		<input name="category" id="category" type="hidden" value="" >
	                  	<input type="hidden" name="zizhiType" id="zizhiType" class="layui-input"     autocomplete="off"     placeholder="请选择证件类型">
	                  	<input type="text" name="categoryname"  id="categoryname" class="layui-input"     placeholder="请输入证件类型">
	                </div> 
	   			</div>
	   			 <div class="layui-form-item">
    				<label class="layui-form-label"><i>*</i>供求关系 : </label>
    				<div class="layui-input-inline"  style="width:70%">
    					 <input type="radio" name="buystate" value="1"   checked="checked" title="买"  lay-filter="filter" lay-skin="primary" > 
					    <input type="radio" name="buystate" value="0"    title="卖" lay-filter="filter" lay-skin="primary">  
	                </div>
    			</div>
	   			<div class="layui-form-item categoryselect">
	   				<label class="layui-form-label"><i>*</i><span>数量 : </span></label>
	                   <div class="layui-input-inline" style="width:80%">
							<input name="count" id="count" type="text" value=""  class="layui-input" placeholder="请输入证书所需数量">
	                   </div>
	   			</div> 
	   			<!-- <div class="layui-form-item categoryselect">
	   				<label class="layui-form-label"><i>*</i><span>结束时间 : </span></label>
	                   <div class="layui-input-inline" style="width:80%">
							<input type="text" name="endtime" id="endtime"  class="layui-input" placeholder="请选择结束时间:yyyy-mm-dd" autocomplete="off"  onclick="layui.laydate({elem: this})">
	                   </div>
	   			</div> -->
	   			<div class="layui-form-item categoryselect">
	   				<label class="layui-form-label"><i>*</i><span>性质 : </span></label>
					<div class="layui-input-inline" style="width:80%">
						<select name="types" id="types" class="layui-input layui-unselect">
							<option value="1">初始</option>
							<option value="2">转注</option>
							<option value="3">初转不限</option>
							<option value="4">项目</option>
                       </select>
					</div>
	   			</div>
	   			<div class="layui-form-item categoryselect">
	   				<label class="layui-form-label"><i>*</i><span>用途 : </span></label>
                   <div class="layui-input-inline" style="width:80%">
                       <select name="paperspurpose" id="paperspurpose" class="layui-input layui-unselect">
                           <option value="1">入库</option>
                           <option value="2">项目</option>
                           <!-- <option value="3" >动态核查</option>
                            <option value="0" >其他</option> -->
                       </select>
                   </div>
	   			</div>
	   			<div class="layui-form-item categoryselect">
	   				<label class="layui-form-label">备注 : </label>
	   				<div class="layui-input-inline" style="width:80%">
	   					<textarea placeholder="请输入备注内容" name="remark" id="xqremark" class="layui-textarea"></textarea>
						<input type="hidden" id="cusid" name="cusid" value="${customerid}">
					</div>
	   			</div>
	   			<div class="layui-form-item tc_btndiv">
	   				<input type="hidden" value="" id="categoryid" name="id">
	            </div>
            </div>
   		</form>
		
		
   
 </div>
        
    <!-- 文件弹窗 -->
    <div class="addwjtc">
    	<div class="tc_customerfilediv">
    		<form class="layui-form" action="" method="post" id="tc_customerfileform" enctype="multipart/form-data">
    			<div class="layui-form-item">
    				<label class="layui-form-label">业务类型 : </label>
    				<div class="layui-input-inline" id="others" style="width:70%">
    					<!-- <input type="radio" name="remarks" value="合同" title="合同" lay-filter="filter" lay-skin="primary" > 
					    <input type="radio" name="remarks" value="营业执照" title="营业执照" lay-filter="filter" lay-skin="primary"> 
					    <input type="radio" name="remarks" value="资质证书" title="资质证书" lay-filter="filter" lay-skin="primary">   
					    <input type="radio" name="remarks" value="其他" title="其他"    lay-filter="filter" lay-skin="primary"> 
					    <input type="text" name="otherremarks" id="otherremarks" value="" style="display:none;width:200px;" autocomplete="off" class="layui-input" placeholder="请描述文件内容 "> 
	                	<input type="text" name="remark" id="fsremarks" style="display:none"   class="layui-input">
	                	 -->
	                	 <input name="fileid" id="fileid" type="hidden">
	                	 <select name="btype"  id="btype">
	                       <dic:cf type="2"     name="customer_business"  value=""    />
	                    </select>
	                </div>
    			</div>
    			<div class="layui-form-item">
    				<label class="layui-form-label">业务备注 : </label>
    				<div class="layui-input-inline" style="width:70%">
    			     <textarea name="remark" placeholder="请填写业务备注" class="layui-textarea"></textarea>
    			    </div> 
    			</div>
    			<div class="layui-form-item">
    				<label class="layui-form-label">选择文件 : </label>
    				<div class="layui-input-inline" style="width:70%">
    					<input type="file" id="upfile" name="file" class="layui-input"/>
    				</div>
    			</div>
    			<div class="layui-form-item tc_btndiv">
    				<input type="hidden" value="0" id="customerfileid" name="fileid">
	            </div>
    		</form>
    	</div>
    </div>
    
    <!-- 联系记录弹窗 -->
    <div class="addlxjl">
    	<form class="layui-form" id="tjlxjlForm" action="">
	      <div class="layui-form-item address" style="margin-top:10px">
	            <label class="layui-form-label">联系人： </label>
	            <div class="layui-input-block" style="width:60%">
	                  <select name="contact" id="contact"  lay-filter="contact">
	                    	<option value="">请选择</option>
	                 </select>
	            </div>
	        </div>
		     <div class="layui-form-item layui-form-text">
			    <label class="layui-form-label"><i>*</i><span>备注：</span></label>
			    <div class="layui-input-block" style="width:60%">
			      <textarea id="remark" name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
			        <input name="id" id="jlid" type="hidden" value="0">
			    </div>
			 </div>
	    </form>
    </div>
    
    <!-- 预约记录弹窗 -->
    <div class="addyyjl">
    	<form class="layui-form" action="" id="bookingform">
			<div class="TM-booking-to" style="padding:10px 20px;">
				<div class="layui-form-item">
					<label class="layui-form-label">预约时间：</label>
					<div class="layui-input-block" style="width:60%">
						<input type="text" name="stime" id="stime" placeholder="YYYY-MM-DD hh:mm:ss" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this, min: laydate.now(0), istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
	    			</div>
    			</div>
    			<div class="layui-form-item">
					<label class="layui-form-label">备注：</label>
				    <div class="layui-input-block" style="width:60%">
				      	<textarea name="remark" id="email-inner" placeholder="请输入内容" class="layui-textarea"></textarea>
				    </div>
			    </div>
			</div>
		</form>
    </div>
    
         <!-- 聘用时间弹窗 -->
    <div class="addpytime"  style="display:none">
    	<form class="layui-form" action="" >
			<div class="TM-booking-to" style="padding:10px 20px;">
				<div class="layui-form-item">
					<label class="layui-form-label">聘用时间：</label>
					<div class="layui-input-block" style="width:60%">
						<input type="text" name="pytime" id="pytime" placeholder="YYYY-MM-DD hh:mm:ss" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this,  istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
	    			</div>
    			</div>
			</div>
		</form>
    </div>
    
 <!-- 住建部查询记录弹窗 -->
    <div class="zjbcx" style="display:none">
			<div class="TM-booking-to" style="padding:10px 20px; ">
				<div class="layui-form-item">
					<label class="layui-form-label">企业名称：</label>
					<div class="layui-input-block zjbqymc" style="width:60%;padding:9px 15px;">
	    			</div>
    			</div>
    			<div class="layui-form-item">
					<label class="layui-form-label">联系人：</label>
				    <div class="layui-input-block zjblxr" style="width:60%;padding:9px 15px;">
				    </div>
			    </div>
			    <div class="layui-form-item">
					<label class="layui-form-label">联系电话：</label>
				    <div class="layui-input-block zjblxdh" style="width:60%;padding:9px 15px;">
				    </div>
			    </div>
			    <div class="layui-form-item">
					<label class="layui-form-label">资质类别：</label>
				    <div class="layui-input-block zjbzzlb" style="width:60%;padding:9px 15px;">
				    </div>
			    </div>
			     <div class="layui-form-item">
					<label class="layui-form-label">地址：</label>
				    <div class="layui-input-block zjblxdz" style="width:60%;padding:9px 15px;">
				    </div>
			    </div>
			</div>
    </div>
	
	
    
</div>

 <form action="http://jzsc.mohurd.gov.cn/dataservice/query/comp/list" method="post"  id="zzcxform" target="_blank"> 
          <input id="apt_code" name="apt_code" type="hidden" value="">
          <input name="qy_name" 	value="" type="hidden" />
		  <input name="qy_code" value="" type="hidden" />
		  <input name="apt_certno" value="" type="hidden"  /> 
		  <input name="qy_fr_name" value="" type="hidden"  />
          <input id="qy_gljg" name="qy_gljg"  value="" type="hidden"  /> 
          <input id="qy_reg_addr_sb" name="qy_reg_addr"  type='hidden' /> 
		  <input type="hidden" id="qy_region" 	name="qy_region" value=""> 
		 <input type='hidden' name='complexname' value='${cuinfo.cname}'>
  </form>
<%@ include file="/WEB-INF/page/public/zzbz.jsp"%>

<div class="Mask ZZmask"></div>

 
<!-- 添加证书弹框 -->
	<div id="TM-layui-zhengshu" style="display: none;">
		<div class="tab-condition" style="margin-left: 35px;">
			<form class="layui-form clefix" action="" id="zssearch">
				<div class="layui-form-item">
					<div class="layui-input-block">
						<input type="text" name="keyWord" id="zskeyword"
							autocomplete="off" placeholder="请输入关键字" class="layui-input">
						 <input type="hidden" id="skpg" name="skipToPage" value="1">
					</div>
				</div>
				<div class="layui-form-item">
				<div class="layui-input-inline ">
					 <select name="uid"  id="seluid"  lay-search>
                    	<option value="">请选择用户</option>
                    	<option value="-1" <c:if test="${ -1 == pager.params.uid }">selected</c:if> >全部</option>
                    	<c:forEach var="nameobj" items="${userlist}">
                    		<option value="${nameobj.uid}" <c:if test="${ nameobj.uid == pager.params.uid }">selected</c:if> >${nameobj.name}</option>
                    	</c:forEach>
                    </select>
				</div> 
				</div>  
				<div class="layui-form-item">
		            <div class="layui-input-inline">
		                   <select name="source" id="source">
		                       <option value="">客户来源</option>
		                       <option value="0" >全部</option>
		                       <dic:cf type="2" name="customer_source" value=""/>
		                   </select>
		             </div>
			  </div> 
				<div class="layui-form-item">
					<button class="layui-btn TM-btn-search zssearchbtn" type="button">
						<i class="layui-icon layui-unselect layui-tab-close">&#xe615;</i>搜索
					</button>
					<button class="layui-btn TM-btn-search zscleanbtn" type="button">
						<i class="layui-icon layui-unselect layui-tab-close">&#xe615;</i>清空
					</button>
				</div>
			</form>
		</div>
		<div class="entering">
			<table class="site-table table-hover TM-table3"
				style="width: 99%; margin: 0 auto;">
				<thead>
					<tr>
						<th style="width: 122px;">姓名</th>
						<th style="width: 100px;">证书及专业</th>
						<th style="width: 171px;">地区</th>
						<th style="width: 171px;">聘用企业</th>
						<th style="width: 172px;">所属人</th>
						<th style="width: 101px;">操作</th>
					</tr>
				</thead>
				<tbody class="tb_customerzs">
				</tbody>
			</table>
			<div class="admin-table-page">
				<div id="zspage" class="page zspage"></div>
			</div>
		</div>
	</div>
	
	 
    <div class="addlgjjl"  style="display: none;">
    	<form class="layui-form" id="tjlxjlForm" action="">
	      <div class="layui-form-item address" style="margin-top:10px">
	            <label class="layui-form-label">跟进内容：</label>
	            <div class="layui-input-block" style="width:60%">
	            	 <textarea id="remark" name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
	            </div>
	        </div>
	    </form>
    </div>
  

	<script id="zslb" type="text/html"> 
{{#  layui.each(d.resultList, function(index, item){ }} 
<tr  >
		                <td>{{item.cname}}</td>
						<td>{{# if(item.technicalpost==null){ }} {{#  } else { }}  {{item.technicalpost}} {{#  } }} </td>
						<td>{{# if(item.address==null){ }} {{#  } else { }}  {{item.address}} {{#  } }}</td>
                         <td>{{# if(item.qyname==null){ }} {{#  } else { }}  {{item.qyname}} {{#  } }}</td>
		                <td>{{item.createusersname}} </td>
		                <td>
							{{# if(item.quid==null){ }} 
  								<button class="layui-btn  layui-btn-small addzs" data="{'id':'{{item.id}}','uid':'{{item.uid}}','name':'{{item.cname}}','createname':'{{item.createusersname}}','advancemoney':'{{item.advancemoney}}'}"   type="button">聘用<i class="layui-icon"></i></button>
							{{#  } else { }} 
	 						    <button class="layui-btn layui-btn-disabled layui-btn-small "   type="button">已聘用<i class="layui-icon"></i></button>
							 {{#  } }} 
		                </td>
	               	</tr>
 
{{#  }); }}  
</script>

 
 
	<script type="text/javascript" src="<%=basePath%>js/customeruserlist.js?v=<%=callcenterstate%>35"></script>

<script id="dyjl" type="text/html"> 
{{#  layui.each(d.list, function(index, item){ }} 
       <tr>
	      <td>{{item.name}}</td>
	      <td>{{item.updatedate.substring(0,10)}} {{item.updatedate.substring(10,16)}}</td>
	      <td>{{#  if(item.remark!=null){ }} {{item.remark}}  {{#  } }} </td>
	      <td>{{#  if(item.uname!=null){ }} {{item.uname}}  {{#  } }} </td>
        </tr> 
{{#  }); }} 
</script>
<script>

(function($,window,document,undefined){ //用一个自调用匿名函数把插架代码包裹起来，防止代码污染
    $.fn.mySelect = function (options) {
        var defaults = {          //defaults 使我们设置的默认参数。
            Event : "click",      //触发响应事件
            msg : "Holle word!"   //显示内容
        };

        var inputobj = $("#"+options.inputid);
        var inputobjvalue = inputobj.val();
        var inpuarray = inputobjvalue.split(",");
        console.log(inpuarray) 
        var options = $.extend(defaults, options);    //将传入参数和默认参数合并
      
        var $this = $(this);      //当然响应事件对象
        // $this.live(options.Event, function (e) {   //功能代码部分，绑定事件
        //     alert(options.msg);
        // });
       //生成option-item并追加展示
       var checkedArr = [];
 			var checkedIDArr = [];
        var html = '';
 		html += '<div class="select-picker-search">';
 		html += '<div class="select-picker-search-checked">请选择</div>';
 		html += '</div>';
 		html += '<div class="select-picker-options-wrp">';
 		//html += '<div class="select-picker-options-serch">';
 		//html += '<input type="text" placeholder="">';
 		//html += '</div>';
 		html += '<div class="select-picker-options-list">';
 		$this.find("option").each(function(){ 
 			let _this = $(this);
 			html += '<div class="select-picker-options-list-item" dataid="'+_this.attr("value")+'">';

			if(inpuarray!=null&&inpuarray.length>0){
                var chk ="duihao-nocheck";
	            for(var i=0;i<inpuarray.length;i++){
					if(inpuarray[i]==_this.attr("value")){
						chk="duihao-checked";
						checkedArr.push($.trim(_this.text()))
						break;
				    }
                } 
            	html += '<b class="duihao '+chk+'"></b>';
			}else{
				html += '<b class="duihao duihao-nocheck"></b>';
			}
 			
 		
 			html += '<span>'+_this.text()+'</span>';
 			html += '</div>';
 		})
 		html += '</div>';
 		html += '</div>'; 
	 	$this.append(html);

	 	if (checkedArr.length > 0) {
		    $this.find('.select-picker-search-checked').text(checkedArr.join(','));
		   // $this.find('.select-picker-search-checked').text(checkedIDArr.join(','));
		    // $this.find('.select-picker-search-checked').text(checkedArr.join(',')).css('color', '#fff');
		} else {
		    $this.find('.select-picker-search-checked').text('请选择').css('color', '#757575');
		}
	 	
	 	// 下拉显示隐藏
	 	$this.on('click',".select-picker-search", function (e) {   //功能代码部分，绑定事件
           	$(this).next('.select-picker-options-wrp').toggle();
	 	 	$(this).next('.select-picker-options-wrp').find('.select-picker-options-serch input').focus();
        }); 
        // 点击选中或不选
 		$this.on('click',".select-picker-options-list-item",function(){ 
 			let _this = $(this);
 			checkedArr = [];
  			checkedIDArr = [];
 			if(_this.find('.duihao-nocheck').length > 0){
				_this.find('.duihao').removeClass('duihao-nocheck').addClass('duihao-checked');
 			}else{
				_this.find('.duihao').addClass('duihao-nocheck').removeClass('duihao-checked');
 			}
 			// 循环遍历options中选中的项添加到选项栏中
 			
			$this.find(".select-picker-options-list-item").each(function(){ 
				let _this = $(this); 
				if(_this.find('.duihao-checked').length > 0){ 
					checkedArr.push($.trim(_this.text()))
					 
					checkedIDArr.push($.trim(_this.attr("dataid")))
				}
			})
			if (checkedArr.length > 0) {
			    $this.find('.select-picker-search-checked').text(checkedArr.join(','));
			    inputobj.val(checkedIDArr.join(',')+",");
			   // $this.find('.select-picker-search-checked').text(checkedIDArr.join(','));
			    // $this.find('.select-picker-search-checked').text(checkedArr.join(',')).css('color', '#fff');
			} else {
				 inputobj.val("");
			    $this.find('.select-picker-search-checked').text('请选择').css('color', '#757575');
			}
 		})
 		// 前端实现下拉搜索 
 		$this.on('keyup',".select-picker-options-serch input",function(){  
 			var text = $(this).val();
 			var html = '';
 			$this.find("option").each(function(){ 
	 			let _this = $(this);
	 			if(_this.text().indexOf(text) != -1){
		 			html += '<div class="select-picker-options-list-item">';
		 			html += '<b class="duihao duihao-nocheck"></b>';
		 			html += '<span>'+_this.text()+'</span>';
		 			html += '</div>';
	 			}
	 		})
	 		if(html == ''){
	 			html += '<p style="text-align:center;">没有相关内容</p>';
	 		}
	 		$this.find(".select-picker-options-list").html('').append(html);
 		})
    }
    // 点击document任意地方 下拉消失
  $(document).click(function (event) {
    var _con = $('.select-picker-options-wrp'); // 设置目标区域
    var _con2 = $('.select-picker-search-checked'); // 设置目标区域
    if (!_con2.is(event.target) && !_con.is(event.target) && _con.has(event.target).length === 0) { // Mark 1 
      $('.select-picker-options-wrp').hide(); //淡出消失
    }
  });
})(jQuery,window,document); 
 
    layui.use(['laypage','laytpl','form','laydate'], function() {
        var $ = layui.jquery,
                layer = layui.layer,
                laytpl = layui.laytpl,
                laypage = layui.laypage;
        
        var form = layui.form();
    	
      var jobselobj=   $("#zizhiType").jobsel({
           	'inputName' : "category"
           });
      
      jobselobj.init();
 $("#demo1").mySelect({inputid:"xzuser"});
$("#demo2").mySelect({inputid:"tags"});
      
      $(".callphone").on("click",function(){
    	  if(callcenterstate==0){
      		layer.msg('请开通轻客呼叫中心' );
      		return false;
			}
    	  
 	      var phone =$(this).attr("data");
 	      var cusid =$("#id").val();
 	     $(".lxjladd").click();
	      
  	 	layer.confirm('请确认电话：'+phone, {
    		  btn: ['确认拨打'] //可以无限个按钮
    	      ,shade: 0
    		  ,btn1: function(index, layero){
    			 	 layer.msg('正在拨号，请勿关闭界面', {icon: 16},function(){
	       			 layer.confirm('通话中：'+phone, {
	       				   anim:2,
	       				   offset: 't',
	       	        		  btn: [ '挂断'] 
	       	        	      ,shade: 0
	       	        		  ,btn1: function(index, layero){
	       	        			  layer.msg('正在挂断电话...', {icon: 16},function(){});
	       	        			  /* var status =  localStorage.getItem('workbenchSdkStatus');
	       	        			  if(status>=8&&status<=12){
	       	        				    localStorage.setItem('workbenchSdkHangup', Math.random())
	       	        			  }   */
	       	        			 $.ajax({
	        	               			type : "get",
	        	               			url : "http://127.0.0.1:3366/callhang?callback=cb_callout",
	        	               			async:false,
	        	               			dataType : "html",
	        	               			success : function(data){
	        	               				result = data;
	        	               				//eval(result); 
	        	               			 
	        	               			}
	        	               		}); 
	       	        		  }
	       			   }); 
	       		   }); 
    			  var telurl ="http://127.0.0.1:3366/callout?phone="+phone+"&callback=cb_callout&recordId="+cusid+"-"+currentuserid;
      			  $.ajax({
              			type : "get",
              			url : telurl,
              			async:false,
              			dataType : "html",
              			success : function(data){
              				result = data;
              			//	eval(result); 
              	  }});
	       	      /* var status =  localStorage.getItem('workbenchSdkStatus');
	   			  if(status==3||status==4||status==5){
	   				  	  var value = {'callee':phone, 'random': Math.random()};
			        	      localStorage.setItem('workbenchSdkCall', JSON.stringify(value)); 
	   			  }   */
    		  } 
    		});  
    }) 
      
 $("#toqyzzcx").on("click",function(){
    	  $("#zzcxform").submit();
      })  
$(".qyxxcx").on("click",function(){
    	   var url = 'https://www.baidu.com/s?wd=${cuinfo.cname}';
	     	  layer.open({
	     		   type: 2, 
	     		   content: url  ,
	     		   area:['50%','90%'],
	     		   btnAlign: 'c'
	     	   });
      })  
      
      $(".gsdcx").on("click",function(){
    	  var tel =$(this).attr("data");
    	  var url = 'https://www.baidu.com/s?wd='+tel;
    	  layer.open({
    		   type: 2, 
    		   content: url  ,
    		   area:['50%','90%'],
    		   btnAlign: 'c'
    	   });
       }) 
       
      $(".sllgsdcx").on("click",function(){
    	  var tel =$(this).attr("data");
    	  var url = 'https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&q='+tel;
    	  layer.open({
    		   type: 2, 
    		   content: url  ,
    		   area:['50%','90%'],
    		   btnAlign: 'c'
    	   });
       }) 
      
       
        var vother=0;
		form.on('radio(filter)', function(data){
				if(data.value=="其他"){
					vother=1;
					$("#fsremarks").val("");
					$("#otherremarks").show();
					 
				}else{
					vother=0;
					$("#otherremarks").val("");
					$("#otherremarks").hide();
					form.render();
					
					$("#fsremarks").val(data.value);
				}  
			 // console.log(data.elem); //得到checkbox原始DOM对象
			  //console.log(data.elem.checked); //是否被选中，true或者false
			 // console.log(data.value); //复选框value值，也可以通过data.elem.value得到
			 // console.log(data.othis); //得到美化后的DOM对象
		});  
     
      var isc=0;//是否已查看
      $("#toqyzjbcx").on("click",function(){
    	    
    	  if(isc==0){
    			$.ajax({
            		type : "post",
            		url : "/getcominfo",
            		async : false,
            		data : {comp : '${cuinfo.cname}'},
            		dataType : "json",
            		success : function(data){
            			if(data!=null&&data._qymc!=null){
            				$(".zjbqymc").html(data._qymc);
                			$(".zjblxr").html(data._lxr);
                			$(".zjblxdh").html(data._lxdh);
                			$(".zjbzzlb").html(data._qyzzlb +"  "+data._zzdj );
                			$(".zjblxdz").html(data._txdz);
            			}
            			isc =1;
            		}
            	}); 
    	  }
    	 layer.open({
      		  	type:1,
		  		title:"住建部信息",
		  		zIndex: 999, 
	           	btnAlign:'c',
		  		shadeClose:true,
		  		content: $(".zjbcx"),
		  		area:['60%','50%'],
		  		maxWidth:800 
      		}); 
    	
      })  
      
   	//分页按钮
  	laypage({
          cont: 'page',
          curr:  '${lxpager.pageNo}'
          ,pages: '${lxpager.totalPages}' //总页数
          ,
          groups: 5 //连续显示分页数
          ,
          skip: true,
          jump: function(obj, first) {
              //得到了当前页，用于向服务端请求对应数据
              var curr = obj.curr;
              if(!first) { 
              	$.ajax({
            		type : "post",
            		url : "/customer/customerdynamic",
            		async : false,
            		data : {skipToPage : curr,cusid : '${customerid}'},
            		dataType : "json",
            		success : function(data){
            			//alert(data)
            			 var getTpl = $("#dyjl").html();
				 laytpl(getTpl).render(data, function(html){
					  
					 $(".lxjlbody").html(html);
					  //view.innerHTML = html;
					});
            			 
            		}
            	});
              	 
              }
          }
      }); 
      
      
	   var id = $("#province").val();
	   if(id>0){
		   var html = city.getCityByPid(id);
			   $("#city").html(html);
			   var cv =  $("#city").attr("value"); 
			   if(cv>0){
				 $("#city").val(cv); 
			   }
			   //更新渲染  
	    	   form.render(); 
	   }
      
        //省份城市选择
    	form.on('select(province)', function(data){
    		var id = $("#province").val();
    		var html = city.getCityByPid(id);
			$("#city").html(html);
			//更新渲染
	    	form.render('select');
    	});
        
        //监听提交
        form.on('submit(back)', function() {
        	var type = $("#type").val();
        	var state = $("#states").val();
        	var url = "/customer/entman/ty"+type+"_st"+state;
        	window.location.href = url;
         });
        
        //验证唯一标识符是否已经存在
    	jQuery.validator.addMethod("checkfirm", function(value,element) {
        	var flag = true;
        	value = $.trim(value);
        	$.ajax({
        		type : "post",
        		url : "/customer/checkisexist",
        		async : false,
        		data : {value : value,types : 2},
        		dataType : "json",
        		success : function(data){
        			if(data == 2) {
        				flag = false;
        			} else if (data == 1) {
        				flag = false;
        			} else if (data == 0) {
        				flag = true;
        			}
        		}
        	});
            return flag;
        }, "名称已存在");
        
    	//验证唯一标识符是否已经存在
    	jQuery.validator.addMethod("checkcname", function(value,element) {

    		var iszj = $('input[name="iszj"]:checked').val();
			if(iszj ==1){
				 return true;
		    } 
        	
        	var flag = true;
		var id = $("#id").val();
        	 if(id.length<1){
        		 id =null;
        	 }
        	value = $.trim(value);
        		$.ajax({
        		type : "post",
        		url : "/customer/checkisexist",
        		async : false,
        		data : {value : value,types : 1,id:id},
        		dataType : "json",
        		success : function(data){
        			if(data >0) {
        				flag = false;
        			} else{
        				flag = true;
        			}
        		}
        	});
            return flag;
        }, "企业名称已存在");
    	
    	//验证框架，验证手机号码是否正确
    	jQuery.validator.addMethod("checkphone",function(value,element) {
    		var flag = true;
    		var phone = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/;
    		flag = phone.test(value);
    		return flag;
    	}, "手机号码格式不正确");
    	
    	//验证框架,验证QQ号码是否正确，最多12位qq
    	jQuery.validator.addMethod("checkqq",function(value,element) {
    		var flag;
    		if (value == null || value.length == 0 ) {
    			flag = true;
    		} else {
    			var qq = /^[1-9][0-9]{4,11}/;
        		flag = qq.test(value);
    		}
    		return flag;
    	}, "qq号码格式不正确");

        
        //录入客户验证
		$("#enterform").validate({
			
	    	rules: {
	    		cname : {
	    			required:true,
	    			checkcname:true,
	    			rangelength:[2,20] 
	    		},
	    		city: {
	    			required:true,
	    		},
	    		province: {
	    			required:true,
	    		},
	    	/* 	firm: {
	    			required:true,
	    			checkfirm:true,
	    			rangelength:[2,6] 
	    		}, */
	    		tel: {
	    			required:true,
				checkphone:true
	    		},
	    		name: {
	    			required:true,
	    		},
	    	},
	    	messages: {
	    		cname : {
	    			required:"请输入企业名称",
	    			checkcname:"企业名称已存在",
	    			rangelength:"长度在2-20之间", 
	    		},
	    		city: {
	    			required:"请选择城市",
	    		},
	    		province: {
	    			required:"请选择省份",
	    		},
	    		firm: {
	    			required:"请输入唯一标识符",
	    			checkfirm:"唯一标识符已经存在",
	    			rangelength:"长度在2-10之间", 
	    		},
	    		tel: {
	    			required:"请输入号码",
				checkphone:"请填写正确的手机号码"
	    		},
	    		name: {
	    			required:"请输入姓名",
	    		},
	    	},
	    	errorPlacement: function(error, element) {
				layer.tips(error.text(), element, {
					tips: [2,tipColor],
	     		 tipsMore: true
	     		});
	   		}, 
	   	 submitHandler: function(form) {
	   		 var iszj = $('input[name="iszj"]:checked').val();
	   		 var cname = $.trim($("#cname").val());
	   		 var address = $.trim($("#address").val());
	   		 var firm =cname;// $.trim($("#firm").val());
	   		 var state = $("#state").val();
	   		 var summary = $("#summary").val();
	   		 var city = $("#city").val();
	   		 var province = $("#province").val();
	   		 var createdate = $("#createdate").val();
	   		 var paperspurpose = $("input[name='paperspurpose']:checked").val();
	   		 var id = $("#id").val();
	   		 var type = $("#type").val();
	   		 var tel = $("#tel").val();
	   		 var name = $("#names").val();
	   		 var level = $("#level").val();
	   		 var source = $("#source").val();
	   		 var zzleval  =$("#zzleval").val();
			 var account  =$("#account").val();
	   		 var password  =$("#password").val();
	   		 var passwordtwo  =$("#passwordtwo").val();
	   		 var accounttwo  =$("#accounttwo").val();
	   		 var xzuser = $("#xzuser").val();
			var tags = $("#tags").val();
	   		 $.ajax({
	   			 type : "post",
	   			 url : "/customer/savecustomer",
	   			  data : {iszj:iszj,tags:tags,xzuser:xzuser,account:account,password:password,passwordtwo:passwordtwo,accounttwo:accounttwo,id:id,address:address,level:level,zzleval:zzleval,source:source,name:name,tel:tel,type:type,cname:cname,firm:firm,state:state,summary:summary,city:city,province:province,createdate:createdate,paperspurpose:paperspurpose},
	   			 dataType : "json",
	   			 async : false,
	   			 success : function(data){
	   				 if (data == 0) {
	   					layer.msg("客户录入失败");
	   				 } else {
	   					layer.msg("客户录入成功");
	   					window.location.href = "/customer/updatecustomer"+data;
					}
	   			 }
	   		 });
	      }
	    });
        
		
		  //设置主要联系人
        $(document).on("click",".maincustomercontacts",function(){
        	var id = $(this).attr("did");
        	var cusid = $(this).attr("dcusid");
    		$.ajax({
	   			 type : "post",
	   			 url : "/customer/savemaincustomercontacts",
	   			 data : {id:id,cusid:cusid},
	   			 dataType : "json",
	   			 async : false,
	   			 success : function(data){
	   				 if (data == 0) {
	   					layer.msg("设置主要联系人失败");
	   				 } else {
	   					layer.msg("设置主要联系人成功");
	   					window.location.href = "/customer/updatecustomer"+cusid;
					}
	   			 }
	   		 });
        	
        });
        
        //添加联系人
        $(document).on("click",".addlxr",function(){
        	$("#contactsid").val("");
        	document.getElementById("tc_customercontactsform").reset();
        	var addtype = $(this).attr("data");
        	layer.open({
        		type:1,
	   		  	btn:['确定','取消'],
	           	btnAlign:'c',
	           	shadeClose:true,
		  		title:"添加联系人",
		  		zIndex: 999,
		  		content: $(".addlxrtc"),
		  		area:['40%','400px'],
		  		maxWidth:800,
		  		yes: function(layero, index){
		  			$("#tc_customercontactsform").submit();
		  		}   		
        	});
        });
        
        //添加需求
        $(document).on("click",".addxq",function(){
        	$("#categoryid").val("");
        	document.getElementById("tc_savecustomercategoryform").reset();
        	layer.open({
        		type:1,
	   		  	btn:['确定','取消'],
	           	btnAlign:'c',
	           	shadeClose:true,
		  		title:"添加需求信息",
		  		zIndex: 999,
		  		content: $(".addxqtc"),
		  		area:['70%','70%'],
		  		maxWidth:800,
		  		yes: function(layero, index){
		  			$("#tc_savecustomercategoryform").submit();
		  		}   		
        	});
        });
        
        //添加文件
        $(document).on("click",".addwj",function(){
        	document.getElementById("tc_customerfileform").reset();
                var fileid = $(this).attr("dataid");
        	var title = (fileid==null?"添加业务":"修改业务");
        	layer.open({
        		type:1,
	   		  	btn:['确定','取消'],
	           	btnAlign:'c',
	           	shadeClose:true,
		  		title:title,
		  		zIndex: 999,
		  		content: $(".addwjtc"),
		  		area:['40%','450px'],
		  		maxWidth:800,
		  		yes: function(layero, index){
		        	var file = $("#upfile").val();
				var remark = $("#fsremarks").val();
		        	
		        	
		        	var otherremark= $("#otherremarks").val();
					/* if(vother==1&&otherremark.length<1){
						layer.tips("请输入文件描述", $("#others"), {
		 					tips: [3,tipColor],
		 	     		 tipsMore: true
		 	     		});
						return false; 
					}else  if(vother==0&&remark.length<1){
						layer.tips("请选择文件内容", $("#others"), {
		 					tips: [3,tipColor],
		 	     		 tipsMore: true
		 	     		});
						return false; 
					}else  */if (file == null || file == ""){
		        		
		        		layer.tips("请选择您要上传的文件", $("#upfile"), {
		 					tips: [3,tipColor],
		 	     		 tipsMore: true
		 	     		});
		        		return false;
		        	} else {
		        		$("#fileid").val(fileid==null?"":fileid);
		        		var infoid = $("#id").val();
		        		var url = "/customer/uploadCustomerfilei"+infoid+"_t"+0;
		        		$("#tc_customerfileform").attr("action",url);
		        		layer.msg("文件上传中",function(){
		        			$("#tc_customerfileform").submit();
		        		})
		        	}
		        /* 	if (file == null || file == ""){
		        		layer.msg("请选择您要上传的文件");
		        		return false;
		        	} else {
		        		var infoid = $("#id").val();
		        		var url = "/customer/uploadCustomerfilei"+infoid+"_t"+0;
		        		$("#tc_customerfileform").attr("action",url);
		        		layer.msg("文件上传中",function(){
		        			$("#tc_customerfileform").submit();
		        		})
		        	} */
		  		}   		
        	});
        });
        
        
        $("#tc_customercontactsform").validate({
	        	rules: {
	        		name : {
		    			required:true,
		    		},
		    		phone: {
		    			required:true,
					checkphone:true
		    		},
		    	},
		    	messages: {
		    		name : {
		    			required:"请输入姓名",
		    		},
		    		phone: {
		    			required:"请输入电话",
					checkphone:"请填写正确的手机号码"
		    		},
		    	},
		    	errorPlacement: function(error, element) {
					layer.tips(error.text(), element, {
						tips: [2,tipColor],
		     		 tipsMore: true
		     		});
		   		}, 
		   	 submitHandler: function(form) {
		   		 var name = $("#name").val();
		   		 $("#name").val("");
		   		 var phone = $("#phone").val();
		   		 var qq = $("#qq").val();
		   		 var webchart = $("#webchart").val();
		   		 var cusid = $("#id").val();
		   		 var contactsid = $("#contactsid").val();
		   		 var isdel = 0;
		   		 
		      	 $.ajax({
		   			 type : "post",
		   			 url : "/customer/savecustomercontacts",
		   			 data : {id:contactsid,cusid:cusid,name:name,phone:phone,qq:qq,webchart:webchart,isdel:isdel},
		   			 dataType : "json",
		   			 async : false,
		   			 contentType: "application/x-www-form-urlencoded; charset=utf-8", 	   			 
		   			 success : function(data){
		   				 
		   				if (contactsid != null && contactsid > 0) {
		   					 //修改
		   					 var html = $(".conttr"+contactsid).html();
		   					 html += "<tr class='conttr"+ data["id"] +"' data='"+ data["id"] +"'>"
		   							+"<td>"+ data["name"] +"</td>"
		                    		+"<td>"+ data["phone"] +"</td>"
		                    		+"<td>"+ data["qq"] +"</td>"
		                    		+"<td>"+ data["webchart"] +"</td>"
			                    	+"<td>"
		                    		+"<button class='layui-btn layui-btn-primary layui-btn-small updatecustomercontacts' type='button'>修改<i class='layui-icon'></i></button>"
		                    		+"<button class='layui-btn layui-btn-primary layui-btn-small deletecustomercontacts' type='button' data='${fileobj.id}'>删除<i class='layui-icon'></i></button>"
		                    		+"<button class='layui-btn layui-btn-primary layui-btn-small maincustomercontacts' type='button'  did='"+data["id"]+"'  dcusid='"+data["cusid"]+"'>主联系人<i class='layui-icon'></i></button>"
		                    		+"</td>"
			                    	+"</tr>";         
		   							$(".conttr"+contactsid).html(html);
		   				 } else {
		   					 //新增
		   					 var html = $(".tb_customercontacts").html();
		   				 		html += "<tr class='conttr"+ data["id"] +"' data='"+ data["id"] +"'>"
			                    +"<td>"+ data["name"] +"</td>"
			                    +"<td>"+ data["phone"] +"</td>"
			                    +"<td>"+ data["qq"] +"</td>"
			                    +"<td>"+ data["webchart"] +"</td>"
			                    +"<td>"
	                 		+"<button class='layui-btn layui-btn-primary layui-btn-small updatecustomercontacts' type='button'>修改<i class='layui-icon'></i></button>"
	                 		+"<button class='layui-btn layui-btn-primary layui-btn-small deletecustomercontacts' type='button' data='${fileobj.id}'>删除<i class='layui-icon'></i></button>"
	                 		+"<button class='layui-btn layui-btn-primary layui-btn-small maincustomercontacts' type='button'  did='"+data["id"]+"'  dcusid='"+data["cusid"]+"'>主联系人<i class='layui-icon'></i></button>"
	                 		+"</td>"
			                    +"</tr>";
			             	$(".tb_customercontacts").html(html);
		   				 }
			            layer.closeAll();
		   			 }
	   		 });
		      }
	        });
        
        //点击保存需求信息
        $("#tc_savecustomercategoryform").validate({
        	rules: {
        		zizhiType : {
	    			required:true
	    		},
	    		categoryname:{
	    			required:true
	    		},
			count : {
	    			digits:true,
	    			required:true
	    		},
	    		endtime : {
	    			required:true
	    		},
	    		types : {
	    			required:true
	    		},
	    		paperspurpose : {
	    			required:true
	    		}
	    	},
	    	messages: {
	    		zizhiType : {
	    			required:"请选择所需证书"
	    		},
	    		categoryname : {
	    			required:"请输入证件类型"
	    		},
	    		count : {
	    			digits:"请输入正确的数量",
	    			required:"请输入所需数量"
	    		},
	    		endtime : {
	    			required:"请选择结束时间"
	    		},
	    		types : {
	    			required:"请选择性质"
	    		},
	    		paperspurpose : {
	    			required:"请选择用途"
	    		}
	    	},
	    	errorPlacement: function(error, element) {
				layer.tips(error.text(), element, {
					tips: [2,tipColor],
	     		 tipsMore: true
	     		});
	   		}, 
	   	 submitHandler: function(form) {
	  		 
		 
			var ctname =$("#zizhiType").val(); 
	   		var data = $("#tc_savecustomercategoryform").serialize();
	   		var categoryid = $("#categoryid").val();
		 	$.ajax({
		 		type : "post",
		 		url : "/customer/savecustomercategory",
		 		data : data,
		 		dataType : "json",
		 		async : false,
		 		contentType: "application/x-www-form-urlencoded; charset=utf-8", 
		 		success : function(data){
		 			if(data['id']!=null){
		 				layer.msg("添加成功",{icon: 1},function(){
    						window.location.reload();
    					});
		 			}else{
		 				layer.msg("添加失败",{icon: 0},function(){
    						window.location.reload();
    					});
		 			}
		 			return  false;
		 			
		 			if (categoryid != null && categoryid > 0 ) {
		 				//修改
		 				var html = $(".catetr"+categoryid).html();
		 				html += "<tr class='catetr"+ data["id"] +"' data='"+ data["id"] +"'>"
	                	+"<td>"+ ctname +"</td>"
	                	+"<td>"+ data["count"] +"</td>"
	                	+"<td>"+ data["type"] +"</td>"
	                	+"<td>"+ data["paperspurpose"] +"</td>"
	                	+"<td>"+ data["endtime"] +"</td>"
	                	+"<td>"+ data["remark"] +"</td>"
	                	+"<td>"
	                	//+"<button class='layui-btn layui-btn-primary layui-btn-small updatecustomercategory' type='button'>修改<i class='layui-icon'></i></button>"
	                	+"<button class='layui-btn layui-btn-primary layui-btn-small deletecategory' type='button'>删除<i class='layui-icon'></i></button>"
	                	+"</td>"
	                	+"</tr>";
	                	$(".catetr"+categoryid).html(html);
		 			} else {
		 				//新增
		 				var html = $(".tb_customercategory").html();
			 			html += "<tr class='catetr"+ data["id"] +"' data='"+ data["id"] +"'>"
			                	+"<td>"+ ctname +"</td>"
			                	+"<td>"+ data["count"] +"</td>"
			                	+"<td>"+ data["type"] +"</td>"
			                	+"<td>"+ data["paperspurpose"] +"</td>"
			                	+"<td>"+ data["endtime"] +"</td>"
			                	+"<td>"+ data["remark"] +"</td>"
			                	+"<td>"
			                	//+"<button class='layui-btn layui-btn-primary layui-btn-small updatecustomercategory' type='button'>修改<i class='layui-icon'></i></button>"
			                	+"<button class='layui-btn layui-btn-primary layui-btn-small deletecategory' type='button'>删除<i class='layui-icon'></i></button>"
			                	+"</td>"
			                	+"</tr>";
			            $(".tb_customercategory").html(html);
		 			}
		            layer.closeAll();
		 		}
		 	});
	      }
        	
        });
        
      	//点击修改categorys
        $(document).on("click",".updatecustomercategory",function(){
        	var ids = $(this).parent().parent().attr("data");
        	$.ajax({
        		type: "post",
        		url: "/customer/getcustomercategory",
        		data: {ids:ids},
        		dataType: "json",
        		success:function(data){
        			$("#category").val(data["category"]);
                	$("#types").val(data["type"]);
                	$("#paperspurpose").val(data["paperspurpose"]);
                	$("#remarks").val(data["remark"]);
                	$("#categoryid").val(ids);
			$("#count").val(data["count"]);
                	$("#endtime").val(data["endtime"]);
                	$("#xqremark").text(data["remark"]);
                	$("#categoryid").val(ids);
                	jobselobj.selData();
                	form.render();
                	layer.open({
              		  	type:1,
        		  		title:"修改需求信息",
        		  		zIndex: 999,
        		  		btn:['确定','取消'],
        	           	btnAlign:'c',
        		  		shadeClose:true,
        		  		content: $(".addxqtc"),
        		  		area:['70%','70%'],
        		  		maxWidth:800,
        		  		yes: function(layero, index){
        		  			$("#tc_savecustomercategoryform").submit();
        		  		}
              		});
        		}
        	})
        });
      	
      	//点击修改联系人
      	$(document).on("click",".updatecustomercontacts",function(){
      		var ids = $(this).parent().parent().attr("data");
      		$.ajax({
      			type: "post",
      			url: "/customer/getCustomerContact",
      			data: {ids:ids},
      			dataType: "json",
      			success:function(data){
      				$("#name").val(data["name"]);
					$("#phone").val(data["phone"]);
					$("#qq").val(data["qq"]);
					$("#contactsid").val(ids);
					$("#webchart").val(data["webchart"]);
					layer.open({
              		  	type:1,
        		  		title:"修改联系人信息",
        		  		btn:['确定','取消'],
        		  		zIndex: 999,
        		  		shadeClose:true,
        		  		btnAlign:'c',
        		  		content: $(".addlxrtc"),
        		  		area:['40%','450px'], 
        		  		maxWidth:800,
        		  		yes: function(layero, index){
          				     $("#tc_customercontactsform").submit();
        		  		}
              		});
      			}
      		});
      	});
      	
      	
      
    	//点击下载
      	$(".downloadcunstomerfilesbtn").on("click",function(){
      		var id = $(this).attr("data");
      		//window.location.href = "/file/"+id;
      		window.open("/file/"+id,'target','');
      	});

    	//点击下载
      	$(".downloadcunstomerfilesbtntwo").on("click",function(){
      		var id = $(this).attr("data");
      		//window.location.href = "/viewfile/"+id;
      		window.open("/viewfile/"+id,'target','');
      	});
      	
      	//点击删除
      	$(".detelecustomerfilebtn").on("click",function(){
      		
      		var id = $(this).attr("data");
      		
      		layer.confirm('是否确认删除', {
      		  	btn: ['确认','取消'] //按钮
      		}, function(){
      			$.ajax({
          			type : "post",
          			url : "/customer/deletefileinfo",
          			data : {id:id},
          			dataType : "json",
          			success : function(data){
          				layer.msg("删除成功",function(){
          					window.location.reload();
          				});
          			}
          		})
      		}, function(){
      			layer.closeAll();
      		});
      	});
      	
      	//点击弹出联系记录
      	$(".lxjladd").on("click",function(){
      		var cid = $("#id").val();
      		$.ajax({
 		 		type : "post",
 		 		url : "/customer/customerinfoajax1",
 		 		data : {id:cid},
 		 		dataType : "json",
 		 		async : false,
 		 		success : function(data){
 		 			var html ="";
 		 		    var contacts =	data.contactsItem;
 		 		    var cname = data.cname; 
 		 		    if(contacts!=null&&contacts.length>0){
 		 		    	for(var i =0;i<contacts.length;i++){
 		 		    		 html+="<option value='"+contacts[i].id+"'>"+contacts[i].name+"(电话："+contacts[i].phone+")</option>";
 		 		    	} 
 		 		    	$("#contact").html(html);
 		 		    }else{
 		 		    	$("#contact").html("<option value=''>请选择联系人</option>");
 		 		    }
 		 			form.render(); 
 		 			 layer.open({
	                       type:1,
	                       content:$('.addlxjl'),
	                       btn:['确定','取消'],
	                       btnAlign:'c',
	                       shadeClose:true,
	                       title:cname+'添加联系记录',
	                       area:['26%','280px'],
	                       maxWidth:800,
	                       yes: function(layero, index){
		                   		var ccuid = $("#contact").val();
		                       	var remark = $.trim($("#remark").val());
		                       	var cusid = $("#id").val();
		                       	var url = "/customer/updatecustomer"+cusid;
		                       	if (remark == null || remark.length < 1) {
		                       		layer.msg("请输入联系记录");
		                       		return false;
		                       	}
		                       	$.ajax({
		                       		type : "post",
		                       		url : "/customer/addcontactsdynamicinfo",
		                       		data : {ccuid:ccuid,remark:remark,cusid:cusid},
		                       		dataType : "json",
		                       		success : function(data){
		                       			if (data == 1) {
		                       				layer.msg("添加联系记录成功",{time : 700},function(){
		                       					window.location.reload();
		                       				});
		                       			} else {
		                       				layer.msg("添加联系记录失败",{time : 700},function(){
		                       					window.location.reload();
		                       				});
		                       			}
		                       		}
		                       	});
	                       }
 	                 });
 		 		}
 		 	});
      	});
      	
      	//点击弹出预约记录
      	$(".yyjladd").on("click",function(){
      		layer.open({
	   		  	type:1,
	   		  	btn:['确定','取消'],
	           	btnAlign:'c',
	           	shadeClose:true,
		  		title:"添加预约",
		  		zIndex: 999,
		  		content: $(".addyyjl"),
		  		area:['30%','350px'],
		  		maxWidth:800,
		  		yes: function(layero, index){
		  			
		  			var stime = $("#stime").val();
					var remark = $("#email-inner").val();
					var value = $("#id").val();
					var url = "/customer/updatecustomer"+value;
					$.ajax({
						type : "post",
						url : "/customer/bookingcontactsdynamicinfo",
						data : {stime:stime,remark:remark,value:value},
						dataType : "json",
						success : function(data){
							if (data == 0) {
								layer.msg("预约失败，请重试",{time : 700},function(){
									layer.closeAll();
								});
							} else {
								layer.msg("预约成功",{time : 700},function(){
									window.location.href=url;
								});
							}
						}
					});
  }
      		});
      	});


      	//点击聘用
      	$(".pytimejpbtn").on("click",function(){
      		 var id =  $(this).attr("data");
      		layer.open({
	   		  	type:1,
	   		  	btn:['确定','取消'],
	           	btnAlign:'c',
	           	shadeClose:true,
		  		title:"调整聘用时间",
		  		zIndex: 999,
		  		content: $(".addpytime"),
		  		area:['30%','250px'],
		  		maxWidth:800,
		  		yes: function(layero, index){


		  			 
		  	       
		  	        var cdate = $("#pytime").val();
		  		   
		  			   $.ajax({
		  	        		type : "post",
		  	        		url : "/customer/updqualificationuser",
		  	        		data : {id:id,createdate:cdate},
		  	        		dataType : "json",
		  	        		success : function(data){
		  	        			if (data == 1) {
		  	        				layer.msg("修改聘用时间成功",{icon: 1,shade:0.1,time:2000},function(){
		  	        				   	   window.location.reload();
		  	        				});
		  	        			} else { 
		  	        				layer.msg("修改聘用时间失败",{icon: 2,shade:0.1,time:2000});
		  	        			}
		  	        		}
		  	        	});
               }
      		});
      	});
      	
      	
      	//删除联系人
      	$(document).on("click",".deletecustomercontacts",function(){
      		var ids = $(this).parent().parent().attr("data");
      		var cusid = $("#id").val();
      		
      		layer.confirm('是否确认删除', {
      		  	btn: ['确认','取消'] //按钮
      		}, function(){
      			$.ajax({
    				type : "post",
    				url : "/customer/deletecustomercontactsbyid",
    				data : {id:ids,cusid:cusid},
    				dataType : "json",
    				success : function(data){
    					layer.msg("联系人删除成功",{time:700},function(){
    						window.location.reload();
    					});
    				}
    			});
      		}, function(){
      			layer.closeAll();
      		});
      		
      	});
      	
      	//删除需求
      	$(document).on("click",".deletecategory",function(){
      		var ids = $(this).parent().parent().attr("data");
      		var cusid = $("#id").val();
      		
      		layer.confirm('是否确认删除', {
      		  	btn: ['确认','取消'] //按钮
      		}, function(){
      			$.ajax({
          			type : "post",
          			url : "/customer/deletecustomercategorybyid",
          			data : {id:ids,cusid:cusid},
          			dataType : "json",
          			success : function(data){
          				layer.msg("证书需求删除成功",{time:700},function(){
    						window.location.reload();
    					});
          			}
          		});
      		}, function(){
      			layer.closeAll();
      		});
      		
      	});
var pretime = $('#pretime').html();
      	 $('.gathering').on('click',function(){
             layer.open({
                 title:'建筑业企业资质标准',
                 type:1,  
                 content:$('#TM-layui-pay'),
               //  shadeClose:true,
                 btnAlign:'c',
                 area:['60%','80%'],
                 success: function(layero, index){
                	  $('#txtKey').val($("#zzleval").val());
                      $('#btnSearch').click();
            	  }
             });
           
             
         });
      	 
      	 
       
         $('#btnSearch').click(function () {
             $('#pretime').html(pretime);
             var searchText = $('#txtKey').val();
             if (searchText.length == 0) {
                 layer.msg("请输入搜索关键词!",{time : 1200} );
                 $('#txtKey').focus();
                 return false;
             }
             var regExp = new RegExp(searchText, 'g');
             $('#pretime div').each(function(){
                 var html = $(this).html();
                 var _time = $(this).parent().find("strong").text();
                 var newHtml = html.replace(regExp, '<span class="highlight">' + searchText + '</span>');
                 $(this).html(newHtml);
                 flag = 1;

             })
             if (flag) {
                 if ($(".highlight").size() > 0) {
                     var _top = $(".highlight").eq(0).offset().top-210;
                     $(".layui-layer-content").animate({
                         "scrollTop": _top
                     }, 500)
                 }
             }
         });
    });
    
  
</script>
</body>

</body>
</html>